#ifndef GLBMP_BASIC_USE
#define GLBMP_BASIC_USE
/*
 * Basic external API of glbmp.  If you're using this for an OpenGL project,
 * you don't need to do anything.
 */

/* loads pixel data from specified BMP file into a big buffer of unsigned chars */
unsigned char *
GLBMP_load_pixel_data(const char *filepath, int *width, int *height, int *channels, int force_channels);

/* convenience function to dispose of pixel data buffer after use */
void
GLBMP_free_pixel_data(unsigned char *image);

/* print information contained in bmp headers */
void
GLBMP_print_headers(const char *fpath);


#endif /* GLIMG_BASIC_USE */

#ifndef GLBMP_INTERNAL_USED
#ifdef GLBMP_INTERNAL
/*
 * NOTE: You will not need to use the following macro unless writing you
 *       are working on an implementation of glbmp.h
 *
 * Structure definitions and function declaractions used internally by a
 * glbmp.h implementation.
 */

#include <inttypes.h>

struct GLBMP_file_header
{
    char bfType[2]; /* identifying characters 'BM' */
    uint32_t bfSize; /* size of the file */
    int16_t bfReserved1; /* two reserved variables at 2 bytes each  */
    int16_t bfReserved2;
    uint32_t bfOffBits; /* the offset to the pixeldata section */
};

struct GLBMP_image_header
{
    uint32_t biSize; /* header size - minimum of 40 */
    int32_t biWidth; /* image width in pixels */
    int32_t biHeight; /* image height in pixels */
    uint16_t biPlanes; /* must be 1 */
    uint16_t biBitCount; /* bits per pixel (1/4/8/16/24/32) */
    uint32_t biCompression; /* compression type (0 = uncompressed) */
    uint32_t biSizeImage; /* size of image - uncompressed images can be zero */
    uint32_t biXPelsPerMeter; /* preferred resolution in pixels per meter for (X/Y) */
    uint32_t biYPelsPerMeter;
    uint32_t biClrUsed; /* number of color map entries used */
    uint32_t biClrImportant; /* number of significant colors */
};

/*
 * A struct describing the layout of compliant BMP files
 */
typedef struct GLBMP_bmp_headers
{
    struct GLBMP_file_header fhead;
    struct GLBMP_image_header ihead;
} GLBMP_bmp_headers;

#endif /* GLBMP_INTERNAL */
#endif /* GLBMP_INTERNAL_USED */

